grammar Roller2;

// Based on http://linux.die.net/man/1/roll

@parser::header {
package com.braincasedesigns.roller.parser.generated;
import com.braincasedesigns.roller.parser.models.*;
}

@lexer::header {
package com.braincasedesigns.roller.parser.generated;
}

expression : term ( '+' term | '-' term );

term: number | factor ( ('*'|'/') number ) |
    number ('*'|'/') factor | '(' expression ')';
    
factor: number dice ( ('h'|'H'|'l'|'L') number ) | dice;

dice: ('d' | 'D') ( number | '%' );

number: DIGIT+;

DIGIT: '0'..'9';
